{% extends "admin/change_form.html" %}

{% block extrahead %}
{{block.super}}
<script type="text/javascript" src="{{MEDIA_URL}}djblets/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="{{MEDIA_URL}}rb/js/repositoryform.js?{{MEDIA_SERIAL}"></script>

<script type="text/javascript">
  var BUG_TRACKER_FIELDS = { {% spaceless %}
{% for id, info in adminform.form.BUG_TRACKER_INFO.items %}
      "{{id}}": [ {% spaceless %}
{%  for field in info.fields %}
          "{{field}}"{% if not forloop.last %},{% endif %}
{%  endfor %}
      {% endspaceless %} ]{% if not forloop.last %},{% endif %}
{% endfor %}
  }{% endspaceless %}

  var HOSTING_SERVICE_FIELDS = { {% spaceless %}
{% for id, info in adminform.form.HOSTING_SERVICE_INFO.items %}
      "{{id}}": [ {% spaceless %}
{%  for field in info.fields %}
          "{{field}}"{% if not forloop.last %},{% endif %}
{%  endfor %}
      {% endspaceless %} ]{% if not forloop.last %},{% endif %}
{% endfor %}
  }{% endspaceless %}

  var HOSTING_SERVICE_HIDDEN_FIELDS = { {% spaceless %}
{% for id, info in adminform.form.HOSTING_SERVICE_INFO.items %}
      "{{id}}": [ {% spaceless %}
{%  for field in info.hidden_fields %}
          "{{field}}"{% if not forloop.last %},{% endif %}
{%  endfor %}
      {% endspaceless %} ]{% if not forloop.last %},{% endif %}
{% endfor %}
  }{% endspaceless %}

  var TOOLS_FIELDS = { {% spaceless %}
      "none": [ "raw_file_url", "username", "password" ],
{% for tool in adminform.form.tool.field.queryset %}
      "{{tool.id}}": [ {% spaceless %}
{%  if tool.supports_raw_file_urls %}
           "raw_file_url"
{#   This is kinda ugly. Need a template tag to simplify it. #}
{%   if tool.supports_authentication %},{%   endif %}
{%  endif %}
{%  if tool.supports_authentication %}
           "username", "password"
{%  endif %}
      {% endspaceless %} ]{% if not forloop.last %},{% endif %}
{% endfor %}
  }{% endspaceless %}

  var HOSTING_SERVICE_TOOLS = { {% spaceless %}
{% for id, info in adminform.form.HOSTING_SERVICE_INFO.items %}
      "{{id}}": [ {% spaceless %}
{%  for tool in info.tools %}
          "{{tool}}"{% if not forloop.last %},{% endif %}
{%  endfor %}
      {% endspaceless %} ]{% if not forloop.last %},{% endif %}
{% endfor %}
  }{% endspaceless %}

</script>
{% endblock %}
